<template>
	<view class="article" v-for="(item,index) in article" :key="index" @click="toDetail(item.id)">
		<image v-if="item.thumb" :src="item.thumb" mode=""></image>
		<view class="right">
			<view style="margin-bottom: 25px;">
				<text>{{item.title}}</text>
			</view>
			<view class="bottom">
				<view class="text">{{ item.author }}</view>
				<view>{{item.create_time}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getList
	} from '@/api/article.js'
	import {mixin} from '@/static/mixin.js'
	export default {
		mixins:[mixin],
		data() {
			return {
				article: [],
			};
		},
		created() {
			getList().then(res => {
				console.log(res)
				this.article = res.list;
			})
		},
		methods: {
			toDetail(id) {
				uni.navigateTo({
					url: `/pages/article/detail/index?id=${id}`
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	@import '../../static/font.scss';
	.article {
		display: flex;
		padding: 10px;
		border-bottom: 1px solid $uni-border-color;

		image {
			height: 80px;
			width: 110px;
		}

		.right {
			width: 100%;
			margin-left: 10px;
			position: relative;

			text {
				font-size: $uni-text-size-md;
			}

			.bottom {
				view {
					color: $uni-text-color-grey;
					display: inline-block;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				position: absolute;
				bottom: 0px;
				width: 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;
			}
		}
	}
</style>
